﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace HuiLian.Cloud.Controls
{
    public class RedBorderRadioButton : RadioButton
    {
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text",
            typeof(string), typeof(RedBorderRadioButton), new PropertyMetadata(""));

        /// <summary>
        /// 文字
        /// </summary>
        [Description("文字"), Category("")]
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        /// <summary>
        /// 注册边框
        /// </summary>
        public static readonly DependencyProperty ButtonThicknessProperty = DependencyProperty.Register("ButtonThickness",
            typeof(Thickness), typeof(RedBorderRadioButton), new PropertyMetadata(new Thickness() { Bottom = 0, Left = 0, Right = 0, Top = 0 }, OnPropertyChanged));

        /// <summary>
        /// 按钮字体颜色
        /// </summary>
        [Description("按钮边框"), Category("边框按钮")]
        public Thickness ButtonThickness
        {
            set { SetValue(ButtonThicknessProperty, value); }
            get { return (Thickness)GetValue(ButtonThicknessProperty); }
        }

        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RedBorderRadioButton button = d as RedBorderRadioButton;
            if (e.Property.Name.Equals("Text"))
                button.Text = (string)e.NewValue;
            if (e.Property.Name.Equals("ButtonThickness"))
                button.ButtonThickness = (Thickness)e.NewValue;
        }
    }
}
